﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NFinal.Advanced;

namespace WebApplication1.DDD.Web.Default.login
{
    public class regAction  : Controller
	{
		public regAction(System.IO.TextWriter tw):base(tw){}
		public regAction(string fileName) : base(fileName) {}
		public regAction(HttpContext context):base(context){}
		public regAction(Microsoft.Owin.IOwinContext context):base(context){}
        
        
        public void reg(string name,string pwd)
        {
            var con = new System.Data.SQLite.SQLiteConnection(NFinal.Config.ConfigurationManager.ConnectionStrings["Common"].ConnectionString);
			con.Open();
            #region	var id; 插入并返回ID
			var __reg_id_command__ = new System.Data.SQLite.SQLiteCommand("insert into users(name,pwd) values(@name,@pwd);select last_insert_rowid();", con);
			var __reg_id_parameters__=new System.Data.SQLite.SQLiteParameter[2];
			__reg_id_parameters__[0] = new System.Data.SQLite.SQLiteParameter("@name",System.Data.DbType.String);
			__reg_id_parameters__[0].Value = name;
			__reg_id_parameters__[1] = new System.Data.SQLite.SQLiteParameter("@pwd",System.Data.DbType.String);
			__reg_id_parameters__[1].Value = pwd;
			__reg_id_command__.Parameters.AddRange(__reg_id_parameters__);
				var id = int.Parse(__reg_id_command__.ExecuteScalar().ToString());
			__reg_id_command__.Dispose();
			#endregion
			
            con.Close();
            AjaxReturn(id>0);
        }
    }
}